<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AlterTableOrdersAddColumnPlatformId extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('orders',function (Blueprint $table){
            $table->string('platformId',50)->default('')->comment('用户平台id 微信：unionid 支付宝 openid')->after('userId');
            $table->dropColumn('unionid');
            $table->index('platformId','idx_platformId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('orders',function (Blueprint $table){
            $table->dropColumn('platformId');
            $table->string('unionid')->comment('用户unionid')->after('userId');
        });
    }
}
